#include "chapter-menu-convert.h"

namespace book
{

ChapterMenuConvert::ChapterMenuConvert(std::ostream &out)
    : out_(out) {

    if (!out_) {
        throw StreamError();
    }

    out_ << "<section>";
    out_ << "<ul>";
}

ChapterMenuConvert::~ChapterMenuConvert() {
    out_ << "</ul>";
    out_ << "</section>";
}

void ChapterMenuConvert::feed(const UriPath &uri, const IndexItem &indexItem) {
    out_ << "<li>";
    out_ << "<a href='/article" << uri << "'>";
    out_ << indexItem.title();
    out_ << "</a>";
    out_ << "</li>";
}

} // namespace book
